package com.example.mapper;

import com.example.model.hotel.Hotel;
import com.example.model.hotel.HotelRoomCount;
import com.example.model.hotel.HotelUpdateRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface HotelMapper {
    //新增酒店
    Long save(Hotel hotel);

    //根据酒店名查询
    @Select("select * from hotels where hotel_name=#{name}")
    Hotel getByName(String name);

    //修改酒店信息
    Boolean update(HotelUpdateRequest hotelUpdateRequest);

    //获取酒店信息
    List<Hotel> getHotels(Hotel hotel);

    @Select("select * from hotels;")
    List<Hotel> searchAll();

//    @Select("SELECT  h.id,h.hotel_name, COUNT(r.id) AS roomCount FROM   hotels h  LEFT JOIN rooms r ON h.id = r.hotel_id  GROUP BY h.id,h.hotel_name;")
    List<HotelRoomCount> getHotelRoomCount();
}
